﻿using Rsd.Dudu;
using Rsd.Dudu.Admin.Core;
using Rsd.Dudu.BizModel;
using Rsd.Dudu.Core;
using Rsd.Dudu.ModelProvider;
using Rsd.Dudu.Web;
using Rsd.Dudu.Web.Core;
using Rsd.Dudu.Web.MVC;

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace Rsd.Faith.Core 
{
    /// <summary>
    /// 
    /// </summary>
    public class FaithController : BaseController
    {
        [ApiService("Index", false)]
        override public object Index()
        {
            return new { };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="suoShuQi"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        protected bool CheckSuoShuQi(string suoShuQi,out string msg)
        {
            msg  = "";
            int year = suoShuQi.ConvertTo<int>();
            if (!int.TryParse(suoShuQi, out year))
            {
                msg = string.Format("所属期不是有效的值({0})", suoShuQi); 
                return false; 
            }
            
            if (year < 2000 || year > DateTime.Now.Year)
            {
                msg = string.Format("所属期({0})不在有效值范围（2000-{1}）内。", suoShuQi, DateTime.Now.Year);
                return false;
            }
            return true;
        }

        /// <summary>
        /// 活动当前用户ID
        /// </summary>
        /// <returns></returns>
        protected string GetCurrentUserId()
        {
            if (this.GetSession() == null)
            {
                return "";
            }
            var user = this.GetSessionData<ISysUser>();
            if (user == null)
            {
                return "";
            }

            return user.Key;
        }

        /// <summary>
        /// 获取当前用户
        /// </summary>
        /// <returns></returns>
        protected ISysUser GetCurrentUser()
        {
            return this.GetSessionData<ISysUser>();
        }
    }



}
